﻿using UnityEngine;

public class SlotCar : MonoBehaviour
{
    SlotCarGUI gui;
    float accelerating;

    void Start()
    {
        gui = new SlotCarGUI();
        gui.OnAccelerate += Accelerate;
        accelerating = 0.0f;
    }

    void Update()
    {
        constantForce.force = new Vector3(accelerating, 0.0f, 0.0f);
    }

    /// <summary>
    /// Draw car control.
    /// </summary>
    void OnGUI()
    {
        if (gui != null)
            gui.OnGUI();
    }

    /// <summary>
    /// Accelerate the car changing the force.
    /// </summary>
    /// <param name="value"></param>
    private void Accelerate(float value)
    {
        accelerating = value;
    }
}
